﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Ext.Net.MVC;
using Buffalo.Tourism.DAL;
using Buffalo.Tourism.DAL.Models;
using Buffalo.Lib.Common;
using Buffalo.Administration.DAL;
using Buffalo.Administration.Enum;

namespace Buffalo.Web.Areas.Tourism.Controllers
{
    public class TourGuideController : BaseController
    {
        #region TourGuide
        public ActionResult TourGuideList()
        {
            return CheckPermission( "TourGuide");
        }
        public AjaxStoreResult GetListTourGuide(int limit, int start, string dir, string sort, bool withDefaultItem, string cboCriteria, string txtSearchText)
        {
            try
            {
                int total = 0;
                string criteria = cboCriteria.Equals(GeneralConstant.ALL_ITEMS) ? string.Empty : cboCriteria;
                string searchText = string.IsNullOrEmpty(txtSearchText) ? string.Empty : txtSearchText.Trim();
                List<TourGuide> listTourGuide = new TourGuideDAL().GetListTourGuide(limit, start, dir, sort, criteria, searchText, out total);
                if (Util.ToSafeBool( withDefaultItem))
                    listTourGuide.Insert(0, new TourGuide { Name = "..." });
                return new AjaxStoreResult(listTourGuide, total);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public AjaxStoreResult SaveTourGuides()
        {
            AjaxStoreResult ajaxStoreResult = new AjaxStoreResult(StoreResponseFormat.Save);

            try
            {
                new TourGuideDAL().SaveTourGuides(HttpContext.Request["data"]);
            }
            catch (Exception e)
            {
                ajaxStoreResult.SaveResponse.Success = false;
                ajaxStoreResult.SaveResponse.Message = e.Message;
            }

            return ajaxStoreResult;
        }


        #endregion
    }
}
